﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;

namespace Pear
{
    class Liaison : System.ComponentModel.INotifyPropertyChanged
    {
        private string liaisonName;
        private string tokenImgPath;
        private string record;
        private DateTime lastDatetime;

        public event PropertyChangedEventHandler PropertyChanged;

        public Liaison(string l, string t, string r, DateTime d)
        {
            this.liaisonName = l;
            this.tokenImgPath = t;
            this.record = r;
            this.lastDatetime = d;
        }

        public string LiaisonName
        {
            get { return liaisonName; }
            set
            {
                if (value != liaisonName)
                {
                    liaisonName = value;
                    PropertyChanged(this, new PropertyChangedEventArgs("LiaisonName"));
                }
            }
        }

        public string TokenImgPath
        {
            get { return tokenImgPath; }
            set
            {
                if (value != tokenImgPath)
                {
                    tokenImgPath = value;
                    PropertyChanged(this, new PropertyChangedEventArgs("TokenImgPath"));
                }
            }
        }

        public string Record
        {
            get { return record; }
            set
            {
                if (value != record)
                {
                    record = value;
                    PropertyChanged(this, new PropertyChangedEventArgs("Record"));
                }
            }
        }

        public DateTime LastDateTime
        {
            get { return lastDatetime; }
            set
            {
                if (value != lastDatetime)
                {
                    lastDatetime = value;
                    PropertyChanged(this, new PropertyChangedEventArgs("LastDateTime"));
                }
            }
        }
    }

    class Contacts : IObservable<Liaison>
    {
        private ObservableCollection<Liaison> liaisons;

        public Contacts()
        {
            liaisons = new ObservableCollection<Liaison>();
            liaisons.Add(new Liaison("机器人", "", "", DateTime.Now));
        }

        public ObservableCollection<Liaison> Liaisons { get { return liaisons; } }
        public IDisposable Subscribe(IObserver<Liaison> observer)
        {
            throw new NotImplementedException();
        }
    }
}
